package com.panda.common.dao.redis;

import java.util.Properties;
import java.util.ResourceBundle;

public class RedisParam {

	private static Properties properites = new Properties();

	private static ResourceBundle rb;
	
	private String host;
	
	private int port;
	
	private boolean usingPwd;
	
	private String pwd;
	

	public String getHost() {
		return host;
	}

	public void setHost(String host) {
		this.host = host;
	}

	public int getPort() {
		return port;
	}

	public void setPort(int port) {
		this.port = port;
	}

	public boolean isUsingPwd() {
		return usingPwd;
	}

	public void setUsingPwd(boolean usingPwd) {
		this.usingPwd = usingPwd;
	}

	public String getPwd() {
		return pwd;
	}

	public void setPwd(String pwd) {
		this.pwd = pwd;
	}

	public RedisParam() throws Exception {
		this("redis");
	}

	public RedisParam(String fileName) throws Exception {
		rb = ResourceBundle.getBundle(fileName);
		// String base =
		// this.getClass().getClassLoader().getResource("").toString();
		// //注意:一定要把file:/这个字符去掉,要FileInputStream不是找不到文件的
		// String filePath = base.substring(6,base.length())+fileName;
		// InputStream ips = new BufferedInputStream(new
		// FileInputStream(filePath));
		// this.properites.load(ips);
		init();
	}

	public void init() {
		//服务器
		this.host = rb.getString("host");
		//端口
		this.port = Integer.parseInt(rb.getString("port"));	
		//是否使用密码
		this.usingPwd = Boolean.parseBoolean(rb.getString("usingPwd"));
		//密码
		this.pwd = rb.getString("pwd");

//		pool = new JedisPool(new Config(), host, port);
//		client = pool.getResource();
//		if (isAuth) {
//			client.auth(password);
//		}
//		JOhm.setPool(pool);
	}
}
